﻿@model ScmCostactualViewModel
@{
    Layout = null;
    ViewBag.Title = "计量台账";
    string str = "";
}
<form id="pagerForm" method="post" action="#rel#">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="${model.numPerPage}" />
<input type="hidden" name="orderField" value="${param.orderField}" />
<input type="hidden" name="orderDirection" value="${param.orderDirection}" />
</form>
<div class="panelBar">
    <ul class="toolBar">
        <li><a id="LedgerExportId" class="export" href="javascript:void();" targettype="navTab"
            title="您确定要导出这些记录吗?"><span>导出</span></a></li>
    </ul>
</div>
<table id="targetTable" width="100%" layouth="49" class="list">
    <thead>
        <tr>
            @for (int i = 0; i < Model.dt.Columns.Count; i++)
            {
                <th style="text-align: center">@Model.dt.Columns[i].ColumnName
                </th>
            }
        </tr>
    </thead>
    <tbody>
        @for (int i = 0; i < Model.dt.Rows.Count; i++)
        {
            if (Model.dt.Rows[i][0].ToString().Contains("合计"))
            {
                str = "style=color:red";
            }
            else
            {
                str = "";
            }
            <tr @str>
                @for (int j = 0; j < Model.dt.Columns.Count; j++)
                {
                    if (j == 0)
                    {
                    <td align="center">@Model.dt.Rows[i][j].ToString()
                    </td>
                    }
                    else
                    {
                        if (@Model.dt.Rows[i][j].ToString() == "")
                        {
                    <td align="right">
                        0
                    </td>
                        }
                        else
                        {
                    <td align="right">@Model.dt.Rows[i][j].ToString()
                    </td>
                        }

                    }

                }
            </tr>
        }
    </tbody>
</table>
<script src="../../Areas/SafetyConstruction/Scripts/unis.ylx.app.js"></script>
<script>
    $(document).ready(function () {
        $("#LedgerExportId").bind("click", function () {
            var table = "<table>" + $("#targetTable")[0].innerHTML + "</table>";
            var enCodeTable = encodeURI(table);
            $.ajax(
           {
               url: "/SafetyConstruction/ScmCostActual/ExportExcelTest",
               data: { tableHtml: enCodeTable },
               success: function (res) {
                   window.open(JSON.parse(res).src);
               },
               error: function (res) {

               },
               async: false,
               type: "post"
           });


            //ajaxOpt.AjaxDoActionWidthData("ScmCostActual/ExportExcelTest", table, function (scuess) {

            //}, function (error) {

            //});
        });

    });
</script>
